<template>
  <div class="nav-top-container">
    <div class="black-square">
      <div class="justify-content-end">
        <div class="col-md-auto">
          <a href="/">
            <i class="bi-house-door"></i> 雅马哈发动机首页
          </a>
        </div>
        <div class="col-md-auto" style="margin:0 3%">
          <a href="https://global.yamaha-motor.com/" target="_blank">
            <i class="bi-globe-asia-australia"></i>全球网站
          </a>
        </div>
        <div @mouseenter="() => { is_hovered = false; is_QR_hovered = true }" @mouseleave="is_hovered = true"
          class="large-QRcodes-box">
          <div class="col-md-auto">
            <img v-if="is_hovered" src="@/common/img/qcode.png" alt="二维码">
            <img v-else src="@/common/img/qcode_hover.png" alt="二维码">
          </div>

          <div @mouseenter="is_QR_hovered = true" @mouseleave="is_QR_hovered = false" v-show="is_QR_hovered"
            class="QRcodes-exist">
            <div class="left">
              <img @mouseenter="appIcon_hover" src="@/common/img/icon_weixin-s.svg" alt="">
              <img @mouseenter="appIcon_hover" src="@/common/img/icon_douyin-s.svg" alt="">
              <img @mouseenter="appIcon_hover" src="@/common/img/icon_bilibili-s.svg" alt="">
              <img @mouseenter="appIcon_hover" src="@/common/img/icon_xiaohongshu-s.svg" alt="">
              <span>
                <a href="/api/media/">
                  查看更多&nbsp;>
                </a>
              </span>
            </div>
            <div class="right">
              <img ref="QR_change" src="@/common/marine/weixin.jpg"></img>
            </div>
          </div>
        </div>

      </div>
    </div>

    <div class="white-aquare-infoNav">
      <div class="left">
        <div></div>
      </div>
      <div class="right">
        <div>所有产品&nbsp;<i class="bi-chevron-down"></i>
        </div>
        <div>最新资讯</div>
        <div>经销商查询&nbsp;<i class="bi-chevron-down"></i>
        </div>
        <div>关于雅马哈&nbsp;<i class="bi-chevron-down"></i>
        </div>
        <div>技术&nbsp;<i class="bi-chevron-down"></i>
        </div>
        <div>赛事&nbsp;<i class="bi-chevron-down"></i>
        </div>
      </div>
    </div>
  </div>

</template>
<script setup lang="ts">
import weixin from '@/common/marine/weixin.jpg'
import douyin from '@/common/marine/douyin.jpg'
import bilibili from '@/common/marine/bilibili.jpg'
import xiaohongshu from '@/common/marine/xiaohongshu.jpg'
import { ref, reactive, } from 'vue';
const is_hovered = ref(true)
const is_QR_hovered = ref(false)


const QR_change = ref()
const appIcon_hover = (e: any) => {
  let arr = e.target.src.match(/_\w+/)[0].split('_')[1]
  setTimeout(() => {
    switch (arr) {
      case 'weixin':
        QR_change.value.src = weixin
        break
      case 'douyin':
        QR_change.value.src = douyin
        break
      case 'bilibili':
        QR_change.value.src = bilibili
        break
      case 'xiaohongshu':
        QR_change.value.src = xiaohongshu
        break
    }
  }, 100)
}
</script>


<style lang="scss" scoped>
.nav-top-container {
  position: sticky;
  z-index: 99;
  top: 0;

  .black-square {
    display: flex;
    justify-content: end;
    background-color: black;
    height: 42px;
    padding: 0 85px;

    .justify-content-end {
      flex: .8;
      display: flex;
      justify-content: end;
      align-items: center;

      .col-md-auto {
        a {
          // font-size: 16px;
          text-decoration: none;
          color: white;

          &:link {
            color: white;
          }

          &:hover {
            color: rgb(62, 62, 193);
          }

          i {
            line-height: 1;
            font-size: 1.3em;
            margin-right: 4px;
          }
        }

      }

      .large-QRcodes-box {
        position: relative;

        .QRcodes-exist {
          height: 185px;
          width: 255px;
          background-color: rgb(231, 96, 96);
          position: absolute;
          top: 32px;
          left: -150px;
          display: flex;

          .left {
            flex: .5;
            display: flex;
            flex-direction: column;
            justify-content: space-evenly;
            align-items: center;
            background-color: aliceblue;


            img {
              height: 30px;
              width: 30px;
            }

            a {
              font-size: 13px;
              text-decoration: none;
              color: black;
            }
          }

          .right {
            flex: 1;

            >img {

              height: 100%;
              width: 100%;

            }

          }

        }

      }
    }
  }

  .white-aquare-infoNav {
    height: 70px;
    background-color: #ffffff;
    display: flex;
    justify-content: space-between;

    .left {
      padding: 10px;
      width: 200px;
      height: 100%;

      >div {
        height: 100%;
        width: 100%;
        background: url(../common//img/rwd_identity.png) no-repeat;
        background-size: contain;
        background-position: center right;
      }

    }

    .right {
      width: 750px;
      margin-left: 120px;
      margin-right: 59px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      >div {
        text-align: center;
        color: #858583;
      }
    }
  }
}
</style>